/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sadhar.sipp.anggaranpendapatanuanguktsksasuransimahasiswa;

import java.util.Map;
import org.sadhar.sia.framework.ClassApplicationModule;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;

/**
 *
 * @author hendro
 */
public class PosPendapatanPopupWnd extends ClassApplicationModule{
    private Listbox lstboxPosPendapatan;
    private AnggaranPendapatanUangUKTSKSAsuransiMahasiswaDAO dao;
    public PosPendapatanPopupWnd(){
        dao = new AnggaranPendapatanUangUKTSKSAsuransiMahasiswaDAOImpl();
    }

    public void onCreate()throws Exception{
        lstboxPosPendapatan = (Listbox)getFellow("lstboxPosPendapatan");
        loadPosPendapatan();
    }

    private void loadPosPendapatan()throws Exception{
        lstboxPosPendapatan.getItems().clear();
        for(Map m : dao.listPosPendapatan()){
            Listitem item = new Listitem();
            item.setValue(m);
            item.appendChild(new Listcell(m.get("posPendapatan").toString()));
            lstboxPosPendapatan.appendChild(item);
        }
    }

    public void lstboxPosPendapatanOnSelect()throws Exception{
        Map m = (Map)lstboxPosPendapatan.getSelectedItem().getValue();
        Window window = (Window) this.getRoot().getFellow("contentDiv").getFirstChild();
        Textbox txtboxIdPosPendapatanUnit = (Textbox)window.getFellow("txtboxIdPosPendapatanUnit");
        Textbox txtboxPosPendapatan = (Textbox)window.getFellow("txtboxPosPendapatan");
        txtboxPosPendapatan.setValue(m.get("posPendapatan").toString());
        txtboxIdPosPendapatanUnit.setValue(m.get("idPosPendapatan").toString());
        this.detach();
    }
}
